import apiClient from './index';

// 教师信息响应类型
export interface TeacherInfoResponse {
  code: number;
  content: {
    username: string;
    name: string;
    position: string;
    responsible_classes: Array<{
      class_id: number;
      class_name: string;
      grade: number;
      is_head_teacher: boolean;
      subjects: string[];
      taught_subjects: string[];
    }>;
    role: string;
    unread_message_count: number;
  };
  msg: string;
}

// 学生信息响应类型
export interface StudentInfoResponse {
  code: number;
  content: {
    class_id: number;
    class_name: string;
    class_rank: number;
    grade: number;
    group_id: number;
    group_name: string;
    group_rank: number;
    group_total_points: number;
    pending_exams_count: number;
    performance_points: number;
    student_id: string;
    student_name: string;
    username: string;
    unread_message_count: number;
  };
  msg: string;
}

/**
 * 获取教师个人信息
 */
export const getTeacherInfo = async (): Promise<TeacherInfoResponse> => {
  const response = await apiClient.post<TeacherInfoResponse>('/user/teacher/info');
  return response.data;
};

/**
 * 获取学生个人信息
 */
export const getStudentInfo = async (): Promise<StudentInfoResponse> => {
  const response = await apiClient.post<StudentInfoResponse>('/user/student/info');
  return response.data;
};

export const getStudentInfoById = async (student_id: number): Promise<StudentInfoResponse> => {
  const response = await apiClient.post<StudentInfoResponse>('/user/student/info', 
    {
      "student_id": student_id
    });
  return response.data;
}